 /********************************************************************************************\
 * libeds - extensible data structures library                                                *
 * Copyright (C) 2006, Dan Kruchinin, <just.asgard@gmail.com>                                 *
 *                                                                                            *
 * -> ds.h                                                                                    *
 * Just common interface macros and defenitions.                                              *
 *                                                                                            *
 * This library is free software; you can redistribute it and/or modify it under the terms of *
 * the GNU Lesser General Public License as published by the Free Software Foundation;        *
 * either version 2.1 of the License, or (at your option) any later version.                  *
 *                                                                                            *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;  *
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  *
 * See the GNU Lesser General Public License for more details.                                *
 *                                                                                            *
 * You should have received a copy of the GNU Lesser General Public License along with this   *
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,  *
 * Boston, MA 02111-1307 USA                                                                  *
 \********************************************************************************************/

#ifndef DS_H
#define DS_H

#include "safe_alloc.h"
#include "errors.h"

/* register user function */
#define ds_reg_func(ds, func, type)				\
  (ds)->funcs.type = (func);
/* get user defined function */
#define ds_func(ds, type) (ds)->funcs.type

#define node_key(node) ((node)->key)                /* get node key */
#define node_value(node) ((node)->value)            /* get node value */
#define node_empty(node) (((node) == NULL) ? 1 : 0) /* check if node empty or not */

/* some flags */
#define DS_FUK     0x1 /* data structure must hold only values with uniqueue key */
#define DS_FNOKEYS 0x2 /* comprasion by item */

#define ds_set_flags(ds, f)					\
  (ds)->flags |= (f);
#define ds_clear_flags(ds, f)				\
  (ds)->flags &= ~(f);

typedef char ds_flags_t;

/* type for user defined compare function */
typedef enum ds_cmp {
  DS_CMP_LESS = 0,
  DS_CMP_GRT,
  DS_CMP_EQ,
  DS_CMP_ERR /* should be returned if error occured */
} ds_cmp_t;

#endif /* DS_H */
